﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class DBHelper
    {
        //定义数据库连接字符串
        public static string connStr = "server=.;database=Test;Integrated Security=true";
        //静态增删改
        public static bool GetNonQuery(String sql)
        {
            bool result = false;
            //创建连接对象
            SqlConnection conn = new SqlConnection(connStr);
            //打开连接
            conn.Open();
            //创建命令对象
            SqlCommand cmd = new SqlCommand(sql,conn);
            //执行ExcuteNonQuery
            int number = cmd.ExecuteNonQuery();
            if (number>0)
            {
                result = true;
            }
            return result;
            conn.Close();
        }
    }
}
